/* Universidad del Valle de Guatemala
 * Sara López 12050
 * Matías Vasquez 12186
 * Nombre: Stack.java
 * Sección:21
 */


 /**
 * Clase abstracta para la estructura Lista. Reúne métodos comunes a todas las
 * implementaciones de la misma. Tomado del capítulo 9 del libro Java Structures 
 * de Duane A. Bailey.
 */
public abstract class AbstractList<E> implements List<E> {
   
    /**
     * Pre: ninguna.
     * Post: ninguna.
     */ 
    public AbstractList() {
   
    }

    /** 
     * Pre: ninguna.
     * Post: retorna verdadero si y sólo si la lista no contiene ningún elemento.
     */ 
    public boolean isEmpty() {
        return size() == 0;
    }
  
     
    /**
     * Pre:
     * Post: value is added to beginning of list
     */ 
    public void addFirst(E value) {
        add(0, value);
    }
    
     
    /** 
     * Pre:
     * Post: value is added to end of list
     */ 
    public void addLast(E value) {
        add(size(), value);
    }
    
     
    /**
     * Pre: list is not empty
     * Post: returns first value in list
     */ 
    public E getFirst() {
        return get(0);
    }
    
     
    /**
     * Pre: list is not empty
     * Post: returns last value in list
     */ 
    public E getLast() {
        return get(size() - 1);
    }
    
     
    /**
     * Pre: list is not empty
     * Post: removes first value from list
     */ 
    public E removeFirst() {
        return remove(0);
    }
    
     
    /**
     * Pre: list is not empty
     * Post: removes last value from list
     */ 
    public E removeLast() {
        return remove(size() - 1);
    }
    
     
    /**
     * Pre:
     * Post: value is added to tail of list
     */ 
    public void add(E value) {
        addLast(value);
    }
    
     
    /**
     * Pre: list has at least one element
     * Post: removes last value found in list
     */ 
    public E remove() {
        return removeLast();
    }

     
    /**
     * Pre: list has at least one element
     * Post: returns last value found in list
     */ 
    public E get() {
        return getLast();
    }
}